package ch2linkedlist;

import static ch2linkedlist.Chapter.*;

public class Ex3 {

	public static boolean deleteNode(ListNode n) {
		if (n == null || n.next == null) {
			return false; // Failure
		}
		ListNode next = n.next;
		n.val = next.val;
		n.next = next.next;
		return true;
	}

	public static void main(String ... argv) {
		ListNode head = createSampleList(new int [] {0, 1, 2, 3});
		ListNode node = head.next.next; // data=2
		deleteNode(node);
		print(head);
	}
}
